library xr_image_picker;

import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';

typedef ImagePickerCallback = void Function(BuildContext context);
typedef OnPickImageCallback = void Function(
    double? maxWidth, double? maxHeight, int? quality);

class SheetItem {
  String text;
  ImagePickerCallback voidCallback;

  SheetItem(this.text, this.voidCallback);
}

class HiImagePicker {
  static Future<List<XFile>?> onPickerMultiImage(ImageSource source,
      {BuildContext? context,
        double maxWidth = 800.0,
        double maxHeight = 800.0}) async {
    try {
      final List<XFile>? pickedFileList = await ImagePicker().pickMultiImage(
        maxWidth: maxWidth,
        maxHeight: maxHeight,
        imageQuality: null,
      );
      return Future.value(pickedFileList);
    } catch (e) {
      return Future.error(e);
    }
  }

  static Future<XFile?> onPickImage(ImageSource source,
      {BuildContext? context,
        bool isMultiImage = false,
        double maxWidth = 800.0,
        double maxHeight = 800.0}) async {
    try {
      final XFile? pickedFile = await ImagePicker().pickImage(
        source: source,
        maxWidth: maxWidth,
        maxHeight: maxHeight,
      );
      return Future.value(pickedFile);
    } catch (e) {
      return Future.error(e);
    }
  }
}
